package main
import "fmt"
//指针参数成员函数，只能指针调用
//
type Usb interface{
	start()
	end()
}
type Phone struct{
	Name string
}
type Camera struct{
	Name string
}
func (p* Phone)start(){
	fmt.Printf("%s开启\n",p.Name)
}
func (p* Phone)end(){
	fmt.Printf("%s结束\n",p.Name)
}
func (c *Camera)start(){
	fmt.Printf("%s开启\n",c.Name)
}
func (c *Camera)end(){
	fmt.Printf("%s结束\n",c.Name)
}


type Animal interface{
	GetName()string
	SetName(string)
}
type Cat struct{
	Name string
}
type Dog struct{
	Name string
}
func (c *Cat)SetName(name string){
	c.Name=name
}
func (d *Dog)SetName(name string){
	d.Name=name
}
func (c Cat)GetName()string{
	return c.Name
}
func (d Dog)GetName()string{
	return d.Name
}

func main(){
	phone:=&Phone{Name:"小米"}
	var us Usb;
	us=phone
	us.start()
	us.end()
	camera:=&Camera{Name:"索尼相机"}
	us=camera
	us.start()
	us.end()

	cat:=&Cat{
		Name:"猫咪",
	}
	var animal  Animal=cat
	animal.SetName("熊猫")
	fmt.Println(animal.GetName())

	dog:=&Dog{Name:"哮天犬"}
	animal=dog
	fmt.Println(animal.GetName())
	animal.SetName("中华犬")
	fmt.Println(animal.GetName())
}